<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld"  prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld"  prefix="bean" %>
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/tlds/custom-html.tld" prefix="chtml" %>

<%@ page  import="java.util.*" %>
<%@ page  import="com.erp.framework.util.CommonUtil" %>
<%@ page  import="com.erp.app.common.ProjectConstants" %>
<%@ page  import="org.apache.commons.beanutils.*" %>
<%@ page  import="com.erp.common.web.*" %>
<%@ page import="com.erp.framework.util.user.User" %>


<jsp:useBean id="changePasswordForm" scope="session" type="com.erp.common.web.ChangePasswordForm" />
<% 	User user = (User)session.getAttribute(ProjectConstants.SESSION_USER);
	String userName = CommonUtil.nullToString(user.getUserId());
	String compCode = CommonUtil.nullToString(user.getCompanyCode());
%>
<head>
<title>Change Password</title>
<link rel="stylesheet" href="<%=request.getContextPath()+ "/css/style.css" %>" type="text/css">

<script language="javascript">
var isSubmitted = 0;
 
function doSubmit(event) {
	document.forms[0].pageEvent.value = event;
	isSubmitted = 1;
	document.forms[0].submit();
}

function doLoad() {
	<%
	if (CommonUtil.nullToString((String)session.getAttribute(ProjectConstants.SESSION_ALERT_AFTER_UPDATE_PASSWORD)).equals(ProjectConstants.GENERIC_YES)) {
		session.removeAttribute(ProjectConstants.SESSION_ALERT_AFTER_UPDATE_PASSWORD);
		
		//out.println("var w = window.opener;");
		//w.promptPwdSaved();

		out.println("alert('Password updated.');");			
		out.println("self.close();");

	}
	
	
	%>
}

</script>
</head>
<body onLoad="javascript:doLoad();" bgcolor="#FFFFFF">

<html:form action="/changePassword">
<html:hidden property="pageEvent" />
<html:hidden property="pageMode" />

<input type="button" value="Save" class="button1" onClick="javascript:doSubmit('updatePassword');">
<input type="button" value="Cancel" class="button1" onClick="javascript:self.close();">
<BR>
<font color='red'><html:errors /></font>
<table bordercolor=#808080 cellspacing=1 cellpadding=2 width=80% border=0 bgcolor="#C1C1C1">
	<tr valign=top class="col_label"> 
		<td width=150>User Id:</td>
		<td width=200 class="col_value">
			<%=userName%>
		</td>
	</tr>
	<tr valign=top class="col_label"> 
		<td width=150>Old Password:</td>
		<td width=200 class="col_value">
			<html:password property="oldPasswd" size="10" maxlength="10" styleClass="t2" redisplay="false"/>
		</td>
	</tr>
	<tr valign=top class="col_label"> 
		<td width=150>New Password:</td>
		<td width=200 class="col_value">
			<html:password property="newPasswd" size="10" maxlength="10" styleClass="t2" redisplay="false"/>
		</td>
	</tr>
	<tr valign=top class="col_label"> 
		<td width=150>Confirm New Password:</td>
		<td width=200 class="col_value">
			<html:password property="confirmNewPasswd" size="10" maxlength="10" styleClass="t2" redisplay="false"/>
		</td>
	</tr>
<html:hidden property="companyCode" value="<%=compCode%>" />
<html:hidden property="userCode" value="<%=userName%>"/>
</table>
</html:form>
</body>